#include "board_hardware_config.h"

//#define FLASH_PROTECT
__asm void SystemReset(void)
{
    MOV R0, #1           //; 
    MSR FAULTMASK, R0    //; ??FAULTMASK ????????
    LDR R0, =0xE000ED0C  //;
    LDR R1, =0x05FA0004  //; 
    STR R1, [R0]         //; ??????   
 
deadloop
    B deadloop        //; ???????????????
}

void board_init(void)
{

	/* Enable GPIOA */
	RCC_AHBPeriphClock_Enable(RCC_AHBPERIPH_GPIOA, ENABLE);

    /* Enable GPIOB */
	RCC_AHBPeriphClock_Enable(RCC_AHBPERIPH_GPIOB, ENABLE);

	/* Enable GPIOC clock */
	RCC_AHBPeriphClock_Enable(RCC_AHBPERIPH_GPIOC, ENABLE);

	/* Enable GPIOF clock */
	RCC_AHBPeriphClock_Enable(RCC_AHBPERIPH_GPIOF, ENABLE);

	
    /*USART1 clocks*/
    RCC_APB2PeriphClock_Enable(RCC_APB2PERIPH_USART1, ENABLE);
    
	/*USART2 clocks */
	RCC_APB1PeriphClock_Enable(RCC_APB1PERIPH_USART2, ENABLE);

    	SysTick_Configuration();
    	
    debug_init(115200);
    
    dev_uart1_init(115200);
    dev_uart2_init(115200);

    TA6932_init();



      BSP_IO_Init(LEDR,IODIR_OUT,IO_PuPd_UP,IOOUT_RESET); 
      BSP_IO_Init(LEDG,IODIR_OUT,IO_PuPd_UP,IOOUT_RESET);
      BSP_IO_Init(MAPAN,IODIR_OUT,IO_PuPd_UP,IOOUT_RESET);
      BSP_IO_Init(IR1OUT,IODIR_OUT,IO_PuPd_UP,IOOUT_RESET);  
      BSP_IO_Init(IR2OUT,IODIR_OUT,IO_PuPd_UP,IOOUT_RESET);
      BSP_IO_Init(CIOOUT,IODIR_OUT,IO_PuPd_UP,IOOUT_RESET);  
      BSP_IO_Init(BEEP,IODIR_OUT,IO_PuPd_UP,IOOUT_RESET); 
	
	#ifdef  TA1616_DRIVER
          TA1616_init();
	#endif
	

       Key_driver_init();
    

		
    #ifdef FLASH_PROTECT


    #endif 
	
    
}

